<?php
namespace Module\MC;

use \com\peecfw\module\Module;

/**
 * 
 * Just a simple module for MineCraft game.
 * This will give users view log log files, users can also see OP's and etc.
 * 
 * 
 * @author peec
 * @package Module
 * @subpackage MC
 *
 * @ModuleAnnotation(api = 2.0, version = 0.1, author = "Petter Kjelkenes <kjelkenes@gmail.com>")
 */

class MC extends Module{

	public $minecraftFolder;
	
	
	public function serverUP(){
		return file_exists($this->minecraftFolder.'server.log.lck');
	}
	
	public function Log(){
		$log = str_replace("\n",'<br />',file_get_contents($this->minecraftFolder.'server.log'));
		$this->template->assign('log',$log);
		
		$this->setTPL('log.tpl');
	}
	public function Config(){
		$conf = str_replace("\n",'<br />',file_get_contents($this->minecraftFolder.'server.properties'));
		$this->template->assign('conf',$conf);
		
		$this->setTPL('conf.tpl');	
	}
	

	
	public function Items(){
		$this->setTPL('items.tpl');	
	}
	
	public function run(){

		$this->minecraftFolder = $this->config['pathToMineCraft'];
		
		$this->registerLinkMethod(2, 'Log','Log');
		$this->registerLinkMethod(2, 'Config','Config');
		$this->registerLinkMethod(2, 'Items','Items');
		
		$ops = file($this->minecraftFolder.'ops.txt');
		$this->template->assign('ops',$ops);
		
	}
	
	
	
}
